package wildlife;
import java.sql.*;
public class SendNewsLetter{
public void execute(){
	Connect c=new Connect();
	try{
		ResultSet rs=c.getResult("select * from notifications where timediff(current_timestamp,date)>0 and newsletter=0");
		String str="NEW CONTENT\n";
		while(rs.next()){
			str+=rs.getString("notification");
			str+="\nposted by "+rs.getString("username");
			str+="\n\n";
			c.dml("update notifications set newsletter=1 where id='"+rs.getString("id")+"'");
		}
		rs=c.getResult("select * from users");
		while(rs.next()){
		SendMail1 s=new SendMail1();
		s.message=str;
		s.to=rs.getString("email");
		s.main();
		}
	}catch(Exception e){e.printStackTrace();}
}
}
